# Contributor: Moritz Wilhelmy
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Jakub Skrzypnik <j.skrzypnik@openmailbox.org>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=rxvt-unicode
pkgver=9.31
pkgrel=5
pkgdesc="rxvt fork with improved unicode support"
url="http://software.schmorp.de/pkg/rxvt-unicode.html"
arch="all"
options="!check"  # No test suite.
license="GPL-3.0-or-later"
depends="$pkgname-terminfo"
makedepends="libx11-dev libxft-dev libxt-dev ncurses fontconfig-dev libptytty-dev
	gdk-pixbuf-dev libxrender-dev perl-dev startup-notification-dev libxext-dev"
subpackages="$pkgname-doc $pkgname-terminfo::noarch"
source="http://dist.schmorp.de/rxvt-unicode/rxvt-unicode-$pkgver.tar.bz2
	gentables.patch
	perl-unicode.patch
	rxvt-unicode-kerning.patch
	"

# secfixes:
#   9.31-r0:
#     - CVE-2022-4170
#   9.26-r0:
#     - CVE-2021-33477

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-256-color \
		--enable-font-styles \
		--enable-xim \
		--enable-keepscrolling \
		--enable-selectionscrolling \
		--enable-smart-resize \
		--enable-pixbuf \
		--enable-transparency \
		--enable-frills \
		--enable-perl \
		--enable-mousewheel \
		--enable-text-blink \
		--enable-fading \
		--enable-startup-notification \
		--enable-unicode3 \
		--disable-utmp \
		--disable-wtmp \
		--disable-lastlog
	make
}

package() {
	# despite having a separate terminfo subpackage
	# TERMINFO env var is used by rxvt-unicode makefile
	# leaving it as is ~skrzyp
	export TERMINFO="$pkgdir/usr/share/terminfo"
	install -d "$TERMINFO"

	make DESTDIR="$pkgdir" \
		-C "$builddir" install
}

terminfo() {
	pkgdesc="$pkgdesc (terminfo data)"
	depends=

	install -d "$subpkgdir"/usr/share/terminfo
	mv -v "$pkgdir"/usr/share/terminfo/* \
		"$subpkgdir"/usr/share/terminfo/
}

sha512sums="
4d14ecbbb62de1b1c717277f5aae5cfb536e11392f2d4b82c884c1713f437fce8e9dd69a328fa353a55d068d8ee4121a31900f45191acec172d5dc76652b6255  rxvt-unicode-9.31.tar.bz2
2a973e001dacf900895d0c1045dfffd5a1ca7650669853bd5fdf09819b19a750bb59d913f8bdc83b103e5e0e7cce7f0d2b6184f36a29c1bac86e90c08ae6a475  gentables.patch
1618e10361ed51528bba83edeb335741a049b4b018f41d0946e15566b026cf0b6c424ac7a7eb2cc95588cb206cc9524081a1740aa6b0719f3b6a78ad8709a6b5  perl-unicode.patch
d2fb68b3e11a78328ded4d2d646ffbaae657e9f23f3b4b81e11bc4350dd3e1e7585eeaeee47a70246bdfb7e12fbb667e40a7766989154235064f56ed4ad0a987  rxvt-unicode-kerning.patch
"
